package data

import (
	"gitcode.com/G-YT/baoyou/server/global"
	"gitcode.com/G-YT/baoyou/server/model/common/response"
	dataResp "gitcode.com/G-YT/baoyou/server/model/data/response"
	userResp "gitcode.com/G-YT/baoyou/server/model/user/response"
	"gitcode.com/G-YT/baoyou/server/utils"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

// 引用以避免编译期未使用导入（Swagger 注释中使用了这些类型）
var (
	_ = dataResp.DataDistributionResp{}
	_ = dataResp.ServiceDataResp{}
	_ = []userResp.UserData{}
)

type DataApi struct {
}

// GetDataDistribution 获取数据分布【健管师端】
// @Tags Data
// @Summary 获取数据分布【健管师端】
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=dataResp.DataDistributionResp}
// @Router /data/getDataDistribution [get]
func (dataApi *DataApi) GetDataDistribution(c *gin.Context) {
	HmID := utils.GetHmID(c)
	result, err := dataService.GetDataDistribution(HmID)
	if err != nil {
		global.GVA_LOG.Error("获取数据分布失败", zap.Error(err))
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(result, c)
}

// GetDailyNewUserData 最近7天每日新增用户数【健管师端】
// @Tags Data
// @Summary 最近7天每日新增用户数【健管师端】
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=[]userResp.UserData}
// @Router /data/getDailyNewUserData [get]
func (dataApi *DataApi) GetDailyNewUserData(c *gin.Context) {
	HmID := utils.GetHmID(c)
	result, err := dataService.GetDailyNewUserData(HmID)
	if err != nil {
		global.GVA_LOG.Error("获取最近7天新增用户失败", zap.Error(err))
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(result, c)
}

// GetDiseaseTop10 获取病增Top10【健管师端】
// @Tags Data
// @Summary 获取病增Top10【健管师端】
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=[]userResp.UserData}
// @Router /data/getDiseaseTop10 [get]
func (dataApi *DataApi) GetDiseaseTop10(c *gin.Context) {
}

// GetTodayServiceData 获取今日服务数据【健管师端】
// @Tags Data
// @Summary 获取今日服务数据【健管师端】
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=dataResp.ServiceDataResp}
// @Router /data/getTodayServiceData [get]
func (dataApi *DataApi) GetTodayServiceData(c *gin.Context) {
	HmID := utils.GetHmID(c)
	result, err := dataService.GetServiceData(HmID)
	if err != nil {
		global.GVA_LOG.Error("获取服务数据失败", zap.Error(err))
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(result, c)
}
